﻿<UserControl x:Class="CI.PW.Controls.StatusControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:converter="clr-namespace:WPFExtensions.Converters;assembly=WPFExtensions" ClipToBounds="True" MinWidth="320" MinHeight="280">
    <Control.Resources>      
        <Style TargetType="{x:Type ListBoxItem}">
            <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" />
        </Style>
        <converter:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
    </Control.Resources>
    <UniformGrid>
        <GroupBox Header="Status">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="68"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Label Grid.Column="0" Grid.Row="0" Content="Alive:" Padding="0" />
                <Label Grid.Column="0" Grid.Row="1" Content="Dead:" Padding="0"/>
                <Label Grid.Column="0" Grid.Row="2" Content="Inactive:" Padding="0"/>
                <Label Grid.Column="0" Grid.Row="3" Content="Run Time:" Padding="0"/>
                <Label Grid.Column="0" Grid.Row="4" Content="Sys Time:" Padding="0"/>
                <Label Grid.Column="0" Grid.Row="5" Content="Lag Time:" Padding="0"/>
                <Label Grid.Column="0" Grid.Row="6" Content="System HB:" Padding="0"/>
                <Label Grid.Column="0" Grid.Row="7" Content="State:" Padding="0"/>
                <TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding Path=AliveCount}"/>
                <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding Path=DeadCount}"/>
                <TextBlock Grid.Column="1" Grid.Row="2" Text="{Binding Path=InactiveCount}"/>
                <TextBlock Grid.Column="1" Grid.Row="3" Text="{Binding Path=RunTime}"/>
                <TextBlock Grid.Column="1" Grid.Row="4" Text="{Binding Path=SysTime}"/>
                <TextBlock Grid.Column="1" Grid.Row="5" Text="{Binding Path=LagTime}"/>
                <TextBlock Grid.Column="1" Grid.Row="6" Text="{Binding Path=SystemHB}"/>
                <TextBlock Grid.Column="1" Grid.Row="7" Text="{Binding Path=State}"/>
            </Grid>
        </GroupBox>
        <GroupBox Header="Alive" Visibility="{Binding Path=SimMode, Converter={StaticResource BoolToVisibilityConverter}}">
            <ListView Name="Alive" 
                      ItemsSource="{Binding AliveOrganisms}" 
                      MinWidth="150" 
                      SelectionMode="Single"
                      IsSynchronizedWithCurrentItem="True" >
                <ListView.View>
                    <GridView>
                        <GridViewColumn Width="Auto" Header="Type" DisplayMemberBinding="{Binding Path=Type}"/>
                        <GridViewColumn Width="Auto" Header="Heart beat" DisplayMemberBinding="{Binding Path=Heartbeat}"/>
                        <GridViewColumn Width="Auto" Header="Energy" DisplayMemberBinding="{Binding Path=Energy}"/>
                        <GridViewColumn Width="Auto" Header="Reg" DisplayMemberBinding="{Binding Path=Registered}"/>
                        <GridViewColumn Width="Auto" Header="Born" DisplayMemberBinding="{Binding Path=Born}"/>
                    </GridView>                    
                </ListView.View>
                <ListView.ItemContainerStyle>
                    <Style TargetType="ListViewItem">
                        <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/>
                    </Style>
                </ListView.ItemContainerStyle>
            </ListView>
        </GroupBox>
        <GroupBox Header="Dead" Visibility="{Binding Path=SimMode, Converter={StaticResource BoolToVisibilityConverter}}">
            <ListView Name="Dead"
                      ItemsSource="{Binding DeadOrganisms}" 
                      MinWidth="150" 
                      SelectionMode="Single"
                      IsSynchronizedWithCurrentItem="True" >
                <ListView.View>
                    <GridView>
                        <GridViewColumn Width="Auto" Header="Type" DisplayMemberBinding="{Binding Path=Type}"/>
                        <GridViewColumn Width="Auto" Header="Heart beat" DisplayMemberBinding="{Binding Path=Heartbeat}"/>
                        <GridViewColumn Width="Auto" Header="Energy" DisplayMemberBinding="{Binding Path=Energy}"/>
                        <GridViewColumn Width="Auto" Header="Reg" DisplayMemberBinding="{Binding Path=Registered}"/>
                        <GridViewColumn Width="Auto" Header="Born" DisplayMemberBinding="{Binding Path=Born}"/>
                    </GridView>
                </ListView.View>
                <ListView.ItemContainerStyle>
                    <Style TargetType="ListViewItem">
                        <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/>
                    </Style>
                </ListView.ItemContainerStyle>
            </ListView>
        </GroupBox>
        <GroupBox Header="Inactive" Visibility="{Binding Path=SimMode, Converter={StaticResource BoolToVisibilityConverter}}">
            <ListView Name="Inactive" 
                      ItemsSource="{Binding InactiveOrganisms}"
                      MinWidth="150" 
                      SelectionMode="Single"                   
                      IsSynchronizedWithCurrentItem="True">
                <ListView.View>
                    <GridView>
                        <GridViewColumn Width="Auto" Header="Type" DisplayMemberBinding="{Binding Path=Type}"/>
                        <GridViewColumn Width="Auto" Header="Heart beat" DisplayMemberBinding="{Binding Path=Heartbeat}"/>
                        <GridViewColumn Width="Auto" Header="Energy" DisplayMemberBinding="{Binding Path=Energy}"/>
                        <GridViewColumn Width="Auto" Header="Reg" DisplayMemberBinding="{Binding Path=Registered}"/>
                        <GridViewColumn Width="Auto" Header="Born" DisplayMemberBinding="{Binding Path=Born}"/>
                    </GridView>
                </ListView.View>
                <ListView.ItemContainerStyle>
                    <Style TargetType="ListViewItem">
                        <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/>
                    </Style>
                </ListView.ItemContainerStyle>
            </ListView>
        </GroupBox>        
    </UniformGrid>
</UserControl>
